﻿using System;
using System.Threading.Tasks;
using LayuiMvc.DataEntity;
using LayuiMvc.Logic.Identity;
using Microsoft.AspNet.Identity;
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;

[assembly: OwinStartup(typeof(LayuiMvc.WebUI.Startup))]

namespace LayuiMvc.WebUI
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // 有关如何配置应用程序的详细信息，请访问 https://go.microsoft.com/fwlink/?LinkID=316888
            app.CreatePerOwinContext(EFContext.Create);
            app.CreatePerOwinContext<IdentityUserManager>(IdentityUserManager.Create);
            app.CreatePerOwinContext<IdentitySignInManager>(IdentitySignInManager.Create);
            app.CreatePerOwinContext<IdentityRoleManager>(IdentityRoleManager.Create);

            //配置
            app.UseCookieAuthentication(new CookieAuthenticationOptions()
            {
                AuthenticationType=DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath=new PathString("/Account/Login"),
                CookieName="IdentityCookie"
            });
        }
    }
}
